package com.xtx.air.dao.user.impl;

import com.xtx.air.dao.user.IUserDAO;
import com.xtx.air.dataobject.UserDO;
import com.xtx.dao.BaseDAOImpl;

import java.util.List;

/**
 * User: hanyi
 * Date: 12-2-9
 * Time: 下午8:08
 */
public class UserDAOImpl extends BaseDAOImpl implements IUserDAO{
    @Override
    public List<UserDO> findUser(UserDO user) {
        return executeQueryForList("SELECT-USER","SELECT-USER-COUNT",user);
    }

    @Override
    public List<String> findUserRoleById(Long userId) {
        return queryForList("SELECT-USER-ROLE",userId);
    }

    @Override
    public void updateRoleUserRef(UserDO user) {
        executeUpdate("UPDATE-ROLE-USER-REF",user);
    }

    @Override
    public void updateUser(UserDO user) {
        executeUpdate("UPDATE-USER",user);
    }

    @Override
    public UserDO getUserById(Long userId) {
        return (UserDO)queryForObject("SELECT-USER-BY-ID",userId);
    }

    @Override
    public UserDO getUserByEmail(String email) {
        return (UserDO)queryForObject("SELECT-USER-BY-EMAIL",email);
    }

    @Override
    public void addUser(UserDO userDO) {
        executeInsert("INSERT-USER",userDO);
    }
}
